home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / BuildingBlocks / StackList.cp < prev    next >
Encoding:
Text File  |  1995-07-28  |  1.1 KB  |  69 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        StackList.cp
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef    __STACKLIST__
  15. #include "StackList.h"
  16. #endif
  17.  
  18. #pragma segment SortedList
  19.  
  20. /***********************************|****************************************/
  21.  
  22. const void*
  23. TStack::Pop ()
  24. {
  25.     if ( fTop )
  26.     {
  27.         const void* value = fTop->fValue;
  28.         TStackLink* next = fTop->fNext;
  29.         fTop->fNext = 0;
  30.         fTop = next;
  31.         --fLength;
  32.         return value;
  33.     }
  34.     else
  35.     {
  36.         return 0;
  37.     }
  38. }
  39.  
  40. /***********************************|****************************************/
  41.  
  42. void
  43. TStack::Clear ()
  44. {
  45.     delete fTop;
  46.     fTop = 0;
  47.     fLength = 0;
  48. }
  49.  
  50. /***********************************|****************************************/
  51.  
  52. Boolean
  53. TStack::Contains ( const void* value ) const
  54. {
  55.     const TStackLink* current = fTop;
  56.     
  57.     while ( current )
  58.     {
  59.         if ( current->fValue == value )
  60.             return true;
  61.         else
  62.             current = current->fNext;
  63.     }
  64.     
  65.     return false;
  66. }
  67.  
  68. /***********************************|****************************************/
  69.